home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 July / com!online0702.iso / software / livemotion / DATA1.CAB / Automation / Scripts / Effect - Spiral Exit.js < prev    next >
Encoding:
Text File  |  2002-05-13  |  4.8 KB  |  169 lines

  1. /***************************************************************
  2. ADOBE SYSTEMS INCORPORATED 
  3. Copyright 2002 Adobe Systems Incorporated 
  4. All Rights Reserved 
  5.  
  6. NOTICE:  Adobe permits you to use, modify, and distribute this 
  7. file in accordance with the terms of the Adobe license agreement 
  8. accompanying it.  If you have received this file from a source 
  9. other than Adobe, then your use, modification, or distribution
  10. of it requires the prior written permission of Adobe. 
  11. ***************************************************************/
  12. /***************************************************************
  13. Author: Mary Obelnicki
  14. ***************************************************************/
  15.  
  16. /***************************************************************
  17.  
  18. The following script creates a key frame animation effect on 
  19. the currently selected objects.
  20.  
  21. Function:
  22.     sprialExit(letters, turns, radius, frames, stagger, forward, startNow, keyFrameRate)
  23.  
  24. Arguments:
  25.     <letters> LMObject - an array of the objects to apply the 
  26.         effect. Does not have to be text objects.  It can be 
  27.         any LMObject.
  28.     <turns> integer - the number of rotations (360 degrees)
  29.     <radius> integer - the final radius of the spiral rotation
  30.     <frames> integer - the length of the animation for each 
  31.         object
  32.     <stagger> integer - the number of frames to stagger the 
  33.         start of each animation
  34.     <startNow> boolean - should the animation start now, at 
  35.         the current frame, or end now. 
  36.     <keyFrameRate> integer - the number of frames between key frames.
  37.  
  38. ***************************************************************/
  39.  
  40. /***************************************************************
  41. To change the behavior of this script, make your changes below
  42. ***************************************************************/
  43.  
  44. sprialExit(application.currentComposition.selection, 2, 50, 24, 3, true, true, 1);
  45.  
  46. /***************************************************************
  47. DO NOT EDIT BELOW THIS LINE
  48. ***************************************************************/
  49.  
  50. function sprialExit(letters, turns, radius, frames, stagger, forward, startNow, keyFrameRate)
  51. {
  52.     if(letters.length < 1)
  53.     return; 
  54.     var xsd = new Array;
  55.     var ysd = new Array;
  56.     var oriRot = new Array; 
  57.     var oriScalex = new Array;
  58.     var oriScaley = new Array; 
  59.     var oriOpacity = new Array; 
  60.     var i;
  61.     
  62.     for(i = 0; i < letters.length; i++)
  63.     {
  64.     xsd[i] = letters[i].position.x; 
  65.     ysd[i] = letters[i].position.y;
  66.     oriRot[i] = letters[i].rotation % 360; 
  67.     oriScalex[i] = letters[i].scale.x; 
  68.     oriScaley[i] = letters[i].scale.y;
  69.     oriOpacity[i] = letters[i].opacity;
  70.     }
  71.  
  72.     var xoffst = xsd[0];
  73.     var yoffst = ysd[0];
  74.     for(i = 0; i < xsd.length; i++)
  75.     {
  76.     xsd[i] -= xoffst;
  77.     ysd[i] -= yoffst;
  78.     }
  79.     
  80.     var xaverage=0;
  81.     var yaverage=0;
  82.     for(i=0; i < letters.length; i++)
  83.     {
  84.     xaverage += letters[i].position.x; 
  85.     yaverage += letters[i].position.y; 
  86.     }
  87.  
  88.     xaverage = xaverage/letters.length; 
  89.     yaverage = yaverage/letters.length;
  90.     
  91.     var xs = xoffst -radius; //cl.position.x - 2 * radius; 
  92.     var ys = yaverage; 
  93.     
  94.     var frame0; 
  95.     if (startNow)
  96.      frame0 = letters[0].currentFrame;
  97.     else
  98.     frame0 = letters[0].currentFrame - (stagger * (letters.length - 1) + frames); 
  99.     var angle = -turns*2*Math.PI;
  100.     var dAngledf = angle/frames; 
  101.     
  102.     //set up initial conditions
  103.     
  104.     for (j = 0; j < letters.length; j++)
  105.     {    
  106.  
  107.     var cl = letters[j];            
  108.  
  109.     cl.stopwatch.position = true; 
  110.     cl.stopwatch.rotation = true; 
  111.     cl.stopwatch.scale = true; 
  112.     cl.stopwatch.opacity = true; 
  113.     
  114.     }    
  115.     
  116.     var df;
  117.     
  118.     for (df = 0; df <= frames; df += keyFrameRate)
  119.     {
  120.     var curAngle = dAngledf * df;     
  121.     var curRadius = radius *(1- df/frames);  
  122.     for (j = 0; j < letters.length; j++)
  123.     {
  124.         var i; 
  125.         if(forward)
  126.         i=j;     
  127.         else
  128.         i = letters.length - 1 - j;
  129.         var cl = letters[i];            
  130.         
  131.         cl.currentFrame = frame0 +df + (j * stagger);         
  132.         
  133.         cl.position.x = xs + ((curRadius + xsd[i]) * Math.cos(curAngle));
  134.         cl.position.y = ys + ((curRadius + ysd[i]) * Math.sin(curAngle));
  135.         cl.rotation = curAngle*(180/Math.PI) + oriRot[i]; //maintain original angle through spiral?
  136.         cl.opacity = oriOpacity[i] * ( 1- df/frames);
  137.         cl.scale.x = (1- df/frames) * oriScalex[i];
  138.         cl.scale.y = (1 - df/frames) * oriScaley[i];
  139.         
  140.     }    
  141.     
  142.     
  143.     }
  144.  
  145.     for (j=0; j<letters.length; j++)
  146.     {
  147.     var i; 
  148.     if(forward)
  149.         i=j;     
  150.     else
  151.         i = letters.length - 1 - j;
  152.     var cl = letters[i];            
  153.     
  154.     cl.currentFrame = frame0 + frames + (j * stagger); 
  155.     
  156.     cl.position.x = xs + ((0 + xsd[i]) * Math.cos(0));
  157.     cl.position.y = ys + ((0 + ysd[i]) * Math.sin(0));
  158.     cl.rotation = angle*(180/Math.PI) + oriRot[i]; 
  159.     cl.opacity = 0;
  160.     cl.scale.x = 0;
  161.     cl.scale.y = 0;
  162.     
  163.     }
  164.     
  165. }
  166.  
  167.  
  168.  
  169.